﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Xml;

namespace TaoBaoProject.Common
{
  public static class XmlOps
  {
    private static XmlNodeList GetNodeListFromXML(string path, string rootItem)
    {
      XmlDocument xml = new XmlDocument();
      xml.Load(path);
      XmlNode root = xml.SelectSingleNode(rootItem);
      XmlNodeList lists = root.ChildNodes;

      return lists;
    }
    public static string GetAllSearchItems(string xmlPath)
    {
      //~/Config/DefineSearchItems.xml
      string sb = "";
      XmlNodeList lists = GetNodeListFromXML(xmlPath, "Projects");
      for (int i = 0; i < lists.Count; i++)
      {
        if (lists[i].Attributes["isSearch"].Value == "true")
        {
          sb += lists[i].Name + ";";
        }
      }
      if (sb != "")
      {
        sb = sb.Substring(0, sb.Length - 1);
      }
      return sb;

    }
  }
}